package com.ai.demo.controller;

import com.ai.demo.service.LangChainService;
//import dev.langchain4j.model.chat.request.ChatRequest;
//import dev.langchain4j.model.chat.response.ChatResponse;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * AUTHER: wangyue
 * TIME  : 2025/2/19 : 12:43
 */

@RestController
@RequestMapping("/api/chat")
//@RequiredArgsConstructor
public class ChatController {



    @Autowired
    private LangChainService chatService;

    @PostMapping("/simple")
    public ResponseEntity<ChatResponse> simpleChat(@RequestBody ChatRequest request) {
        String response = chatService.chat(request.getMessage());
        return ResponseEntity.ok(new ChatResponse(response));
    }


    @GetMapping("/get")
    public ResponseEntity<ChatResponse> get(@RequestParam String request) {
        String response = chatService.chat(request);
        return ResponseEntity.ok(new ChatResponse(response));
    }



//    @PostMapping("/with-context")
//    public ResponseEntity<ChatResponse> contextualChat(
//            @RequestHeader("X-User-ID") String userId,
//            @RequestBody ChatRequest request) {
//        String response = chatService.chatWithMemory(userId, request.getMessage());
//        return ResponseEntity.ok(new ChatResponse(response));
//    }


    // DTO定义
    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ChatRequest {
        private String message;
    }

    @Data
    @NoArgsConstructor
    @AllArgsConstructor
    public static class ChatResponse {
        private String response;
    }


}

